#pragma once
#include "vn/IPAddress.h"
#include "vn/IPAddress.h"

void IPAddressTest() {_test_func_;
	// IPAddress constants
	{
		assert(IPAddress(  0,   0,   0, 0  ) == IPAddress::Any);
		assert(IPAddress(255, 255, 255, 255) == IPAddress::Broadcast);
		assert(IPAddress(127,   0,   0, 1  ) == IPAddress::Loopback);
		assert(IPAddress(255, 255, 255, 255) == IPAddress::None);
	}

	// constructors
	{
		const IPAddress a(0x11223344);
//		const IPAddress b(0x3344, 0x1122);
		const IPAddress c(0x44, 0x33, 0x22, 0x11);

		//assert(a == b);
		//assert(b == c);
		assert(a == c);

		assert(IPAddress::Parse("127.0.0.1") == IPAddress::Loopback);

		// IPAddress x = "10.0.0.5";	// avoid this
	}

	// comparators
	{
		const IPAddress a1(1);
		const IPAddress a2(1);
		IPAddress b(2);

		assert(a1 == a1);
		assert(a1 == a2);
		assert(b != a1);

		b = a1;
		assert(b == a1);
	}

	// use htonl
	{
		IPAddress lb(htonl(INADDR_LOOPBACK));
		assert(lb == IPAddress(127, 0, 0, 1));
	}
}
